package com.channel.temperature.collect.app.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.channel.temperature.collect.data.response.OfflineBean

@Dao
interface OfflineBeanDao {

    @Query("SELECT * FROM Offline")
    fun getAll(): List<OfflineBean>?

    @Query("SELECT * FROM Offline where deviceName= :mDeviceName")
    fun getAllByDeviceName(mDeviceName: String): List<OfflineBean>?

    @Update
    fun updateBean(vararg offlineBean: OfflineBean)

    @Insert
    fun insertAll(vararg offlineBeans: OfflineBean)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(offlineBean: OfflineBean)

    @Delete
    fun delete(offlineBean: OfflineBean)

    @Query("DELETE FROM Offline")
    fun deleteAll()

    @Query("DELETE  FROM Offline where deviceName= :mDeviceName")
    fun deleteRoomFromDeviceName(mDeviceName: String)

    @Query("SELECT COUNT(time) FROM Offline ")
    fun queryRoomCount(): Int

    @Query("SELECT COUNT(deviceName) FROM Offline where deviceName= :mDeviceName")
    fun queryRoomCountByDeviceName(mDeviceName: String): Int

    @Query("SELECT DISTINCT deviceName FROM Offline ")
    fun queryRoomDeviceNameList(): List<String>?
}
